x11: Return the exact pixel coverage in get_frame_extents
authorAlexander Larsson <alexl@redhat.com>
Thu, 20 Nov 2014 09:42:55 +0000 (10:42 +0100)
committerAlexander Larsson <alexl@redhat.com>
Thu, 20 Nov 2014 11:38:04 +0000 (12:38 +0100)
Rather than just rounding down the position *and* the size separately
we correctly calculate a rectangle in scaled window coords that fully
covers the real window size. This really only makes a difference
when the window size/position isn't a multiple of the window scale.

https://bugzilla.gnome.org/show_bug.cgi?id=739750

gdk/x11/gdkwindow-x11.c

index c4b90af74b65d707422ba33be5151db7453fbd18..525a798dd1463ddf264e75fe8468757a5825bf43 100644 (file)
@@ -3262,10 +3262,14 @@ gdk_x11_window_get_frame_extents (GdkWindow    *window,
   if (vroots)
     XFree (vroots);
 
-  rect->x /= impl->window_scale;
-  rect->y /= impl->window_scale;
-  rect->width /= impl->window_scale;
-  rect->height /= impl->window_scale;
+  /* Here we extend the size to include the extra pixels if we round x/y down
+     as well as round the size up when we divide by scale so that the returned
+     size is guaranteed to cover the real pixels, but it may overshoot a bit
+     in case the window is not positioned/sized according to the scale */
+  rect->width = (rect->width + rect->x % impl->window_scale + impl->window_scale - 1) / impl->window_scale;
+  rect->height = (rect->height + rect->y % impl->window_scale + impl->window_scale - 1) / impl->window_scale;
+  rect->x = rect->x / impl->window_scale;
+  rect->y = rect->y / impl->window_scale;
   gdk_x11_display_error_trap_pop_ignored (display);
 }